package txAnnotation;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class AspectJ {
	@Pointcut("execution(* txAnnotation.*.*(..))")
	private void aspectJ() {};
	@Before("aspectJ()")
	public void before() {
		System.out.println("开始操作");
	}
	@AfterReturning("aspectJ()")
	public void after() {
		System.out.println("操作成功，无异常");
	}
	@AfterThrowing(value="aspectJ()",throwing = "e")
	public void exception(JoinPoint joinPoint,Throwable e) {
		System.out.println(e.getMessage()+":异常,执行回滚操作；请重试");
	}
	
	
}
